package com.zx.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zx.dao.IStudentsDAO;
import com.zx.model.Students;
@RestController
@RequestMapping("/students")
public class StudentsController {

	@Resource
	private IStudentsDAO studentsDAO;
	
	/**多条件分页查询
	 * @param s
	 * @return
	 */
	@RequestMapping("/findAll.do")
	public Map findAll(Students s) {
		s.setPage((s.getPage()-1)*s.getLimit());
		List<Students> list = studentsDAO.findAll(s);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("msg", "查询成功");
		map.put("count", studentsDAO.getCount(s));
		map.put("data", studentsDAO.findAll(s));
		return map;
	}
	
	/**添加学生信息
	 * @param s
	 * @return
	 */
	@RequestMapping("/add.do")
	public int add(Students s) {
		return studentsDAO.add(s);
	}
}
